Title Banner


Technical Q&A's


ME 01 - Preventing Memory Leaks (1-May-95)


Q When NewPtr() is used to allocate a block of memory in the application heap, is it necessary to use DisposePtr to release this block when the program terminates?

A No. All memory allocated by an application in the application heap (with NewPtr, NewHandle, NewPtrClear, or NewHandleClear) is released by the Process Manager when the application terminates, and the application's heap zone is destroyed. This means that you do not explicitly have to call DisposePtr() to release blocks of memory you allocate with a NewPtr() call before the application exits.

If your application allocates memory in the system heap, then it must deallocate it. Otherwise, leaks occur. Calls that allocate memory in the system heap include NewHandleSys, NewHandleSysClear, NewPtrSys, and NewPtrSysClear.

Technical Support
Technical Q&As
Contents | Next Question

Navigation graphic, see text links

Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help